/**
 * https://leetcode-cn.com/problems/move-zeroes/
 * @param {number[]} nums
 * @return {void} Do not return anything, modify nums in-place instead.
 */
 var moveZeroes = function(nums) {
    let l = 0;
    let r = 0;
    while (r < nums.length) {
        if (nums[l] === 0) {
            while (nums[r] === 0 && r < nums.length) {
                r++;
            }
            // all zero
            if (r === nums.length) {
                break;
            }
            const temp = nums[l];
            nums[l] = nums[r];
            nums[r] = temp;
        }
        l++;
        if (r < l) {
            r++;
        }
    }
};